package com.web.base.open.service;

import com.blue.jdbc.JdbcDataSource;
import com.blue.jdbc.Page;
import com.web.base.open.dao.AccountDao;
import com.web.base.open.model.Account;
import com.web.core.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 开放平台帐号业务层
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2017年02月27日
 */
@Service("openAccountService")
@Transactional
@JdbcDataSource(Const.DS_BASE)
public class AccountService
{
	@Autowired
	private AccountDao accountDao;
	
	public AccountService()
	{
	}
	
	public Account save(Account account)
	{
		if (account.getId() == null)
		{
			accountDao.save(account);
		}
		else
		{
			accountDao.update(account);
		}
		Account a = accountDao.get(account.getId());
		return a;
	}
	
	public Account get(Integer id)
	{
		Account log = accountDao.get(id);
		return log;
	}
	
	public Page<Account> list(Account account, Page<Account> page)
	{
		page = accountDao.list(account, page);
		return page;
	}
	
	public List<Account> list(Account account)
	{
		List<Account> list = accountDao.list(account);
		return list;
	}
	
	public void delete(Account account)
	{
		accountDao.delete(account);
	}
	
}
